<template>
	<view class="status-bar"></view>
	<view class="">
		
			<view v-for="(item,index) in info" :key="index" class="border-bEDEDED pb30 mt30 mr30 ml30">
				<view class="flex-ju-b posire">
					<view class="flex-a-i">
						<image class="image wh76-76 ra76 mr20" :src="item.user.avatar?item.user.avatar:'/static/mo.png'"></image>
						<view>
							<view>{{item.user.nickname}}</view>
							<view class="size22 color999 mt5">{{item.result}}</view>
						</view>
					</view>
					<view @click="toChat(item)" v-if="item.is_care" class="size22 wh114-48 flex-ju-c ra48 border999">
						私信
					</view>
					<view @click="guanzhu(item)" v-else class="size22 wh114-48 flex-ju-c color27A752 ra48 border27A752">
						<uni-icons type="plusempty" color="#27A752" size="13"></uni-icons>
						关注
					</view>
				</view>
			</view>
		
	</view>
</template>

<script>
	export default {
		data() {
			return {
				isdata:false,
				info:[],
				page:1
			}
		},
		onLoad() {
			this.getlist()
			
			
		},
		onReachBottom() {
			this.page++
			this.getlist()
		},
		methods: {
			
			 toChat(item) {
				console.log(item)
				uni.navigateTo({
					url:"message?userinfo="+JSON.stringify(item.user)
				})
			},
			guanzhu(item){
				this.http('/api/add_care/'+item.uid,{},'post').then(res=>{
					item.is_care = true
				})
			},
			getlist(){
				this.http('/api/msg_list',{type:3,page:this.page,limit:20}).then(res=>{
					this.info = [...this.info,...res.data.list]
					if(this.info.length){
						this.isdata=false
					}else{
						this.isdata=true
					}
					
					var buser = uni.getStorageSync('user')
					buser.care_un_read=0
					uni.setStorageSync('user',buser)
				})
			},
			change(e){
				console.log(e)
			},
		}
	}
</script>


<style>

</style>
